<!-- 系统设置 -->
<template>
    <view class="sustem-setting">
        <van-cell-group inset border>
            <van-cell title="账号与安全">
                <template #title>
                    <span class="custom-title">账号与安全</span>
                </template>
            </van-cell>
            <van-cell title="认证中心">
                <template #extra>
                    <span @click="authFn()">{{authStoreName}}<van-icon name="arrow" /></span>
                </template>
            </van-cell>
            <van-cell title="修改密码">
                <template #right-icon>
                    <span @click="updatePassword()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
            <van-cell title="更多设置">
                <template #right-icon>
                    <span @click="settingMore()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
        </van-cell-group>
        <van-cell-group inset border>
            <van-cell title="账号与安全">
                <template #title>
                    <span class="custom-title">聊天设置</span>
                </template>
            </van-cell>
            <van-cell title="新消息设置">
                <template #right-icon>
                    <span @click="newMessage()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
            <van-cell title="隐私设置">
                <template #right-icon>
                    <span @click="privacy()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
            <van-cell title="黑名单">
                <template #right-icon>
                    <span @click="blacklist()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
        </van-cell-group>
        <van-cell-group inset border>
            <van-cell title="账号与安全" >
                <template #title>
                    <span class="custom-title">关于我们</span>
                </template>
            </van-cell>
            <van-cell title="用户协议" v-for="item in state.aboutList" :key="item.id" @click="jump(item)">
                <template #right-icon>
                    <van-icon name="arrow" />
                </template>
            </van-cell>
            <van-cell title="意见反馈">
                <template #right-icon>
                    <span @click="opinionFeedback()"><van-icon name="arrow" /></span>
                </template>
            </van-cell>
        </van-cell-group>
        <van-button type="primary" @click="loginOut()">退出</van-button>
    </view>
</template>
    
<script setup>
import { reactive, getCurrentInstance, onMounted, computed } from "vue"
import { getAuthorization, removeAuthorization } from "@/utils/auth.js"
import { onLoad } from '@dcloudio/uni-app'
import PhotoListItem from "@/components/photoListItem/index.vue"
const state = reactive({
    show: false,
    curIndex: false,
    isEdit: false,
    aboutList:[
        {
            id:1,
            name:"用户协议",
            url:'https://www.ysjcp.com/UserUseAgreement.html'
        },
        {
            id:1,
            name:"隐私协议",
            url:'https://www.ysjcp.com/PrivacyAgreement.html'
        },
        {
            id:1,
            name:"用户规范",
            url:'https://www.ysjcp.com/PlatformUserAgreement.html'
        }
    ]
})


import { AuthStateStore } from "@/store/authIndex.js"
let AuthStore = AuthStateStore()

let authStoreName = computed(() => {
    let zrAuth = AuthStore.$state.authState.find( o => o.RealType == 0)
    let nsAuth = AuthStore.$state.authState.find( o => o.RealType == 1)
    let { RealType,RealState } = zrAuth
    let str = ""
    let zr = {
        0:'未认证',
        1:'真人认证成功',
        2:'真人认证失败'
    }
    let ns = {
        0:'女神认证中',
        1:'女神认证成功',
        2:'女神认证失败'  
    }
    if(RealType == 0 ){
        str = zr[zrAuth.RealState]
    }
    if(RealType == 1 && nsAuth.RealState > 0 ){
        str = ns[nsAuth.RealState]
    }
    return str
})

const jump = (item) => {
    uni.navigateTo({
        url:`/pages/webviewpage/index?pageUrl=${item.url}`
    });
}

onLoad((options) => {

})
const authFn = () => {
    uni.navigateTo({
        url: "/pages/home/person/authentication/index"
    })
}

const updatePassword = () => {
    uni.navigateTo({
        url: "/pages/home/person/updatePassword/index?type=2"
    })

}

// 更多设置
const settingMore = () => {
    uni.navigateTo({
        url: "/pages/home/person/settingMore/index"
    })
}

// 新消息设置
const newMessage = () => {
    uni.navigateTo({
        url: "/pages/home/person/newMessage/index"
    })
}

// 隐私设置
const privacy = () => {
    uni.navigateTo({
        url: "/pages/home/person/privacySetting/index"
    })
}

// 黑名单
const blacklist = () => {
    uni.navigateTo({
        url: "/pages/home/person/blacklist/index"
    })
}

// 意见反馈
const opinionFeedback = () => {
    uni.navigateTo({
        url: "/pages/home/person/opinionFeedback/index"
    })
}

const loginOut = () => {
    removeAuthorization('token')
    removeAuthorization('userInfo')
    uni.navigateTo({
        url: "/pages/login/mobileNumber/index"
    })
}

</script>
    
<style lang="scss" scoped>
.sustem-setting {
    padding-top: 30rpx;
    min-height: 100vh;
    background: #F7F8F9;
}

.van-cell-group {
    margin-bottom: 30rpx;
}

.van-button {
    width: calc(100% - 60rpx);
    height: 100rpx;
    line-height: 100rpx;
    margin-left: 30rpx;
    font-size: 36rpx;
}

.custom-title {
    font-size: 32rpx;
    font-weight: bold;
    color: #262626;
    line-height: 2;
}
</style>
    